#import "BCAboutBoxController.h"

static BCAboutBoxController* BCAboutBoxControllerInstance = nil;

@implementation BCAboutBoxController

+ (BCAboutBoxController*) sharedAboutBoxController
{
    if (BCAboutBoxControllerInstance == nil)
        BCAboutBoxControllerInstance = [[BCAboutBoxController alloc] initWithWindowNibName: @"AboutBox"];
    
    return BCAboutBoxControllerInstance;
}

- (void) awakeFromNib
{
    NSString* nameVersion = [NSString stringWithFormat: @"%@ %@", [BCAboutBoxController applicationName], 
        [BCAboutBoxController applicationVersion]];
    
    [_applicationNameVersion setStringValue: nameVersion];
    
    NSString* creditsPath = [[NSBundle mainBundle] pathForResource: @"Credits" ofType: @"rtf"];
    if (creditsPath != nil)
    {
        NSData* credits = [NSData dataWithContentsOfFile: creditsPath];
        [_creditsTextView replaceCharactersInRange: NSMakeRange(0, [[_creditsTextView string] length])
                                           withRTF: credits];
    }
}

+ (NSString*) applicationName
{
    return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString*)kCFBundleNameKey];
}

+ (NSString*) applicationVersion
{
    return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString*)kCFBundleVersionKey];
}

+ (NSString*) applicationBuild
{
    return @"local";
}

@end
